package com.baitai.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baitai.common.annotation.Log;
import com.baitai.common.core.controller.BaseController;
import com.baitai.common.core.domain.AjaxResult;
import com.baitai.common.enums.BusinessType;
import com.baitai.system.domain.SysUseConsigneeInfo;
import com.baitai.system.service.ISysUseConsigneeInfoService;
import com.baitai.common.utils.poi.ExcelUtil;
import com.baitai.common.core.page.TableDataInfo;

/**
 * 收货人信息Controller
 * 
 * @author xx
 * @date 2024-07-20
 */
@RestController
@RequestMapping("/system/sysUseConsigneeInfo")
public class SysUseConsigneeInfoController extends BaseController
{
    @Autowired
    private ISysUseConsigneeInfoService sysUseConsigneeInfoService;

    /**
     * 查询收货人信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysUseConsigneeInfo sysUseConsigneeInfo)
    {
        startPage();
        List<SysUseConsigneeInfo> list = sysUseConsigneeInfoService.selectSysUseConsigneeInfoList(sysUseConsigneeInfo);
        return getDataTable(list);
    }

    /**
     * 导出收货人信息列表
     */
    @Log(title = "收货人信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysUseConsigneeInfo sysUseConsigneeInfo)
    {
        List<SysUseConsigneeInfo> list = sysUseConsigneeInfoService.selectSysUseConsigneeInfoList(sysUseConsigneeInfo);
        ExcelUtil<SysUseConsigneeInfo> util = new ExcelUtil<SysUseConsigneeInfo>(SysUseConsigneeInfo.class);
        util.exportExcel(response, list, "收货人信息数据");
    }

    /**
     * 获取收货人信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysUseConsigneeInfoService.selectSysUseConsigneeInfoById(id));
    }

    /**
     * 新增收货人信息
     */
    @Log(title = "收货人信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUseConsigneeInfo sysUseConsigneeInfo)
    {
        return toAjax(sysUseConsigneeInfoService.insertSysUseConsigneeInfo(sysUseConsigneeInfo));
    }

    /**
     * 修改收货人信息
     */
    @Log(title = "收货人信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUseConsigneeInfo sysUseConsigneeInfo)
    {
        return toAjax(sysUseConsigneeInfoService.updateSysUseConsigneeInfo(sysUseConsigneeInfo));
    }

    /**
     * 删除收货人信息
     */
    @Log(title = "收货人信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysUseConsigneeInfoService.deleteSysUseConsigneeInfoByIds(ids));
    }
}
